package com.tql.mall.model.enums.category;

import lombok.Getter;

@Getter
public enum OperFailEnum {
    ADD_FAIL_NAME_NULL(1,"类别名称为空！"),
    ADD_FAIL_UPID_NULL(2,"上级分类编号为空或不存在！"),
    DELETE_FAIL_DOWNID_NONULL(3,"被下级编号依赖！"),
    DELETE_FAIL_ID_NULL(4,"id项不存在!"),
    EDIT_FILE_NAME_DEPLICATED(5,"分类名重复！")
    ;

    private Integer status;
    //错误信息
    private String msg;

    OperFailEnum(Integer status,String msg){
        this.status = status;
        this.msg = msg;
    }

    /**
     * 通过状态编号获取出错信息
     * @param status
     * @return
     */
    public static String getStatusNameByStatus(Integer status){
        OperFailEnum[] values = OperFailEnum.values();
        for (OperFailEnum value : values){
            if (status.intValue() == value.getStatus().intValue()){
                return value.getMsg();
            }
        }
        return "";
    }
}
